<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/header.css" rel="stylesheet" />
		<style>
			
			#mui-content {
				width: 100%;
				position: absolute;
				top: 44px;
				bottom: 0px;
				background: #2e3132;
			}
			
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav title">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
			<a id="down_qrcode" class="mui-icon mui-icon-download mui-icon-right-nav mui-pull-right" style="color: white;"></a>
			<h1 class="mui-title title-color">我的二维码</h1>
		</header>
		
		<div id="mui-content" class="mui-content" style="padding: 80px 30px 0px 30px;">
			<div style="background-color: white;padding-top: 20px;padding-left: 20px;">
				<img id="img_user_face" src="../css/registLogin/headimg.jpg" width="60px" style="border-radius: 8%;float: left;"/>
				<label id="lab_nickname" style="float: left;margin-left: 10px;margin-top: 10px;">Crism</label>
			</div>
			<div style="background-color: white;text-align: center;">
		    		<img id="img_my_qrcode" src="../image/qrcode2.png" />
		    </div>
		    <div style="background-color: white;text-align: center;">
		    		<p style="padding-bottom: 10px;font-size: 12px;">扫一扫上面的二维码图案， 可添加我喔</p>
		    </div>
		</div>
	
		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js" type="text/javascript" ></script>
		<script type="text/javascript">
			mui.init({
				swipeBack:true //启用右滑关闭功能
			});
			mui.plusReady(function() {
				var fr_user_info = app.getUserInfo();
			    if(fr_user_info != null){
				    var faceImg = fr_user_info.faceImgBig;
				    var nickName = fr_user_info.nickName;
				    var qrCode =  fr_user_info.qrCode;
				    var lab_nickname = document.getElementById("lab_nickname");
				    var img_my_qrcode = document.getElementById("img_my_qrcode");
				    	lab_nickname.innerHTML = nickName;
				    if(app.isNotNull(faceImg)){
				    	 	var img_user_face= document.getElementById("img_user_face"); 
				    	 	img_user_face.src = faceImg;
				    }
				    img_my_qrcode.src = qrCode;
				    	// 获取手机端可见屏幕宽度
					var imgWidth = document.body.clientWidth-60;
					img_my_qrcode.width=imgWidth;
					img_my_qrcode.height=imgWidth;
			    }
			    var down_qrcode = document.getElementById("down_qrcode");
			    down_qrcode.addEventListener("tap",function(){
			    		plus.nativeUI.showWaiting("正在下载...");
			    		var df_task = plus.downloader.createDownload(
						qrCode,
						{},
						function(df,status){
							plus.nativeUI.closeWaiting();
							// 下载完成
							if(status == 200){ 
								var tempFile = df.filename;
								plus.gallery.save( tempFile, function () {
									app.showToast("Save Success!","success");
								});
							} else {
								app.showToast("Download Error!","error");
							}  
						}
					);
					df_task.start();
			    });
			});
		</script>
	</body>
</html>
